home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 361_01 / tbarmu.c < prev    next >
C/C++ Source or Header  |  1991-09-18  |  2KB  |  69 lines

  1.  
  2. /* TBarMu ---> A Six-Pac of Drop Menu "Hot Zones" w/ Context Sensitive Help.
  3.  *
  4.  * Author: J.Ekwall                                     13 September 91
  5.  *
  6.  * Copyrighted to the Public Domain.  Unlimited Distribution Authorized.
  7.  *
  8.  * User Assumes All Risks/Liabilities.
  9.  *
  10.  * Last Update: 17 September 91/EK
  11.  */
  12.  
  13. #include <stdek.h>
  14. #include <stdio.h>
  15. #include <gadgets.h>
  16. #include <process.h>
  17. #include <keys.h>
  18.  
  19. int TBarMu(char **TBar[], char *Title, long BarColor, long MuColor)
  20. {
  21.  /* Create & display a Menu Bar (w/ Drop-Down Menues) & Query User
  22.   * Returns: (Slot# << 8) + Tag Byte or ESC for hit ESC on Bar Level.
  23.   */
  24.     int i, xx, yy;
  25.     int HiLite, GreyOut, Flag, Lit = 0, Rtn, Slot = 0, Z;
  26.     char FootPrint[321];
  27.     extern char HelpTag[20];
  28.  
  29.  /* Build Menu Bar */
  30.     Getxy(&xx, &yy); Flag = HideCursor(); GreyOut = BarColor & 0xFF;
  31.     HiLite = (BarColor >>= 8) & 0xFF; BarColor >>= 8;
  32.     SaveBox(1, 1, 80, 1, FootPrint); Gotoxy(1,1); ClrTo(80, BarColor);
  33.     for (Z = 0; TBar[Z] != NULL; Z++) {
  34.        strncpy(HelpTag, TBar[Z][0], 10); HelpTag[10] = NULL;
  35.        if (TBar[Z][0][10] IS '+') Dwrite(Z*10, 1, BarColor, HelpTag);
  36.        else Dwrite(Z*10, 1, GreyOut, HelpTag);
  37.        if (Z IS 5) break;
  38.     }
  39.     Dwrite(61, 1, BarColor, Title); RcolorSet(1, 1, HiLite, 10);
  40.  
  41.  /* Scroll Right/Left & Pop Drop Menue(s) */
  42.     for (Rtn = 0; !Rtn; ) {
  43.        switch (Kbq_read()) {
  44.        case F1:
  45.           strncpy(HelpTag, TBar[Lit][0], 10); HelpTag[10] = NULL; TisHelp();
  46.           break;
  47.        case FWD: if (Slot++ IS Z) Slot = 0; break;
  48.        case BWD: if (Slot-- IS 0) Slot = Z; break;
  49.        case ESC: Rtn = ESC; break;
  50.        case DN:
  51.        case CR:
  52.           if (TBar[Lit][0][10]  IS '+') Rtn =
  53.              TMu(TBar[Slot], 1+Slot*10, 2, MuColor, (BarColor << 8)+GreyOut);
  54.           break;
  55.        }
  56.        if (Slot != Lit) {
  57.           if (TBar[Lit][0][10]  IS '+') RcolorSet(1+Lit*10, 1, BarColor, 10);
  58.           else RcolorSet(1+Lit*10, 1, GreyOut, 10);
  59.           Lit = Slot; RcolorSet(1+Lit*10, 1, HiLite, 10);
  60.        }
  61.     }
  62.  
  63.  /* Clean Up & Split */
  64.     RestoreBox(1, 1, 80, 1, FootPrint); Gotoxy(xx, yy);
  65.     if (Flag) ShowCursor(0); if (Rtn IS ESC) return ESC;
  66.     return Rtn + (++Slot << 8);
  67. }
  68.  
  69.